package cate.game.role.mall.msg;

import cate.common.annotation.OperationSetter;
import cate.common.table.d.GDOperation;
import cate.common.util.GameResult;
import cate.game.GameBody;
import cate.game.client.ClientContext;
import cate.game.client.msg.ClientMsg;
import cate.game.client.msg.MsgConfig;
import cate.game.client.msg.MsgInput;
import cate.game.client.msg.id.MsgIdBMall;
import cate.game.role.bag.vo.UidNumVO;
import easy.java.dev.note.NoteField;

import java.util.List;

@ClientMsg(title = "一键购买商品 の 请求")
@OperationSetter(value = GDOperation.MALL_FAST_BUY, sub = "mallId")
public class BuyManyItemsReq implements MsgInput {
    @NoteField(value = "商店ID")
    public int mallId;

    @NoteField(value = "需要购买商品的唯一id", detail = "现在同一个商品可能会刷出多次")
    public List<UidNumVO> items;

    @Override
    public MsgConfig conf() {
        return MsgIdBMall.BUY_MANY_ITEMS_REQ;
    }

    @Override
    public void execute(GameBody game, ClientContext cc) {
        GameResult<Void> r = cc.getRole().getMall().buyItems(mallId, items);
        if(!r.ok()){
            game.notice.message(cc.getRole(), r.message);
        }
    }
}
